package cn.zjitc.ptaLearn.ch07.ex44;

import java.util.Scanner;
/**
 * @author Zixuan Xu
 * @date
 */
/*
    输入两个数，作为矩形的长、宽。
    (② 一个公有的无参数的构造方法，该构造方法将所有成员变量初始化为零；
    ③ 一个公有的有参数的方法void setXY(double a, double b)，该方法用于设置矩形的属性length与width；)
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Rectangle rect = new Rectangle();
        rect.setXY(sc.nextDouble(),sc.nextDouble());
        double area = rect.getArea();
        double perimeter = rect.getPerimeter();
        System.out.printf("面积为%.1f\n",area);
        System.out.printf("周长为%.1f",perimeter);
    }
}

class Rectangle {
    private double length;
    private double width;

    public Rectangle() {
        length = 0;
        width = 0;
    }

    public void setXY(double a, double b) {
        this.length = a;
        this.width = b;
    }

    public double getArea() {
        return length * width;
    }

    public double getPerimeter() {
        return length * 2 + width * 2;
    }
}
